<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <title>备份</title>
    <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <link href="css/icons.css" rel="stylesheet" type="text/css">
</head>
<body>

<div class="card">
    <div class="card-header">
        <h2>备份数据库需要较久的时间请谨慎选择</h2>
    </div>
    <div class="card-body">
        <button type="button" id="backup" class="btn btn-success">备份</button>
    </div>
    <div class="card-footer">

    </div>
</div>

<script src="js/lib/jquery.min.js"></script>
<script src="js/lib/popper.min.js"></script>
<script src="js/lib/bootstrap.min.js"></script>
<script>
    $(function () {
        backup();
    });

    function backup() {
        //备份数据库sql
        $("#backup").on('click', function () {
            if (confirm("备份数据库需要较久的时间，确定进行备份吗？")) {
                $.ajax({
                    type: 'get',
                    url: '/runBackup',
                    beforeSend: function () {
                        $(".card-body").append('<div class="load-img"><img src="css/zTree/metroStyle/img/loading.gif"/></div>');
                    },
                    success: function (result) {
                        if (result.code === 200) {
                            $(".load-img").html(result.msg);
                        } else {
                            $(".load-img").html(result.msg);
                        }
                    },
                    error: function (result) {
                        alert(result);
                    }
                });
            }

        });
    }
</script>
</body>
</html>